<template>
    <div>
        <p>这是首页</p>

        <!-- 显示 Vuex 中获取的 count 状态 -->
        <h1>当前 count：{{ count }}</h1>

        <!-- 点击后累加 count 状态 -->
        <button @click="clickHandler">累加</button>
    </div>
</template>

<script>
import axios from 'axios'

export default {
    computed: {
        count() {
            // 引入 Vuex 中的状态
            return this.$store.state.counter.count
        }
    },

    async created() {
        const result = await axios.get('/api/public/v1/home/swiperdata')
        console.log(result)
    },

    methods: {
        clickHandler() {
            // 调用 Vuex mutations 改变状态
            this.$store.commit('counter/increase')
        }
    }
}
</script>
